package com.radiation.rms.controller;


import com.radiation.rms.common.R;
import com.radiation.rms.entity.Area;
import com.radiation.rms.service.AreaService;
import com.radiation.rms.vo.AddressMapVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import java.util.List;

/**
 * <p>
 * 地点表 前端控制器
 * </p>
 *
 * @author 1062
 * @since 2021-04-02
 */
@RestController
@RequestMapping("/rms/area")
public class AreaController {
    @Autowired
    private AreaService areaService;

    @PutMapping("save/list")
    public R batchSave(@RequestBody(required = false) List<AddressMapVo> addressMapVos) {
        String json = "";
        areaService.batchSave(addressMapVos, null);
        return R.ok();
    }

    @GetMapping("tree")
    public R getAreaTree() {
        return areaService.getAreaTree();
    }

    @GetMapping("path")
    public String getPath(@RequestParam("areaId") String areaId) {
        return areaService.getPath(areaId);
    }

    @PutMapping("save")
    public R saveArea(@RequestBody Area area) {
        return areaService.saveArea(area);
    }

    @GetMapping("init/menu")
    public R getInitArea() {
        return areaService.getInitArea();
    }

    @GetMapping("get")
    public R getAreaById(@RequestParam("areaId") String areaId) {
        Area byId = areaService.getById(areaId);
        return R.ok().data("item", byId);
    }

    @PostMapping("update")
    public R updateArea(@RequestBody Area area) {
        areaService.updateById(area);
        return R.ok();
    }

    @DeleteMapping("delete")
    public R removeBid(@RequestParam("areaId") String areaId) {
        return areaService.removeBid(areaId);
    }
    @GetMapping("get/one/department")
    public List<String> getOneDepartment(@RequestParam("areaId") String areaId){
        return areaService.getOneDepartment(areaId);
    }

    @GetMapping("get/two/department")
    public List<String> getTwoDepartment(@RequestParam("areaId") String areaId){
        return areaService.getTwoDepartment(areaId);
    }
    @GetMapping("get/three/department")
    public List<String> getThreeDepartment(@RequestParam("areaId") String areaId){
        return areaService.getThreeDepartment(areaId);
    }
    @GetMapping("get/parent")
    public List<String> getParent(@RequestParam("areaId") String areaId){
        return areaService.getParent(areaId);
    }
    @GetMapping("init/hospital")
    public R initHospital(){
        return areaService.initHospital();
    }
}

